﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Spawnner : MonoBehaviour {


    public GameObject enemy;
    public Transform[] spawnPos;
    private float timeBtwSpawns;
    public float startTimeBtwSpawns;

	// Use this for initialization
	void Start () {
        
        timeBtwSpawns = startTimeBtwSpawns;
	}
	
	// Update is called once per frame
	void Update () {
		
        if(timeBtwSpawns<=0){

            int randpos = Random.Range(0, spawnPos.Length);
            Instantiate(enemy, spawnPos[randpos].position,Quaternion.identity);
            timeBtwSpawns = startTimeBtwSpawns;

        }else{

            timeBtwSpawns -= Time.deltaTime;
        }
	}
}
